function ajax(url) {
    return new Promise(function (resolve, reject){
        const xhr = new XMLHttpRequest()
        xhr.open("GET", url)
        xhr.responseType = "json"
        xhr.onload = function () {
            if(this.status === 200) {
                resolve(this.response)
                console.log(454545)
            } else {
                reject(new Error(this.statusText))
            }
        }
        xhr.send()
    })
}
ajax("./test.json").then(res => {
    console.log("请求成功: ", res)
}).catch(err => {
    console.log("请求失败: ", err)
})